package com.tmt.im.wallet.config.beans;

import com.tmt.im.wallet.helper.IKAnalyzerHelper;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.List;

/**
 * 敏感关键字字典.
 *
 * @Description TODO
 * @Author wuyi
 * @Date 2024/9/2 15:42
 * @Version 1.0
 **/
@Getter
@Setter
@ConfigurationProperties(prefix = "sensitive-keys")
public class SensitiveKeysProperties {

    private List<String> keys;

    public boolean exist(String content, StringBuilder illegalContent){
        List<String> list = IKAnalyzerHelper.iKSegToList(content);
        for (String item : list) {
            if (keys.stream().anyMatch(x->x.contains(item))){
                illegalContent.append(item);
                return true;
            }
        }
        return false;
    }
}
